"""
规范化数据---->ai接口
"""
from service.get_ai import get_api_ai
import json

require = '不符合要求'   # 机器人回复


def ai_data_standardization(data):
    """
    规范化数据---->ai接口
    :param data: 待规范化的数据
    :return: 规范化后的数据
    """
    try:
        response = get_api_ai(data)

        res_data = json.loads(response.text.split("\n\n")[-3][5:])  # json数据
        if require in res_data['thought']:
            print("机器人回复:", res_data['thought'])
            return False
        else:
            print("机器人回复:", res_data['thought'])
            return True

    except Exception as e:
        print(f"机器人api接口时发生错误: {e}")
        return False

